<!DOCTYPE html>
<html class="pixel-ratio-1"><head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>茵曼商城</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=0">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="css/sm.min.css">
    <link rel="stylesheet" href="css/sm-extend.min.css">
    <link rel="stylesheet" href="css/inman.css">
    <script src="https://hm.baidu.com/hm.js?5ee51ef74fa865950bb9a2757fdb33ad"></script><script type="text/javascript" src="js/zepto.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/sm.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/sm-extend.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/functions.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/TouchSlide.1.1.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/jweixin-1.0.0.js"></script>
    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?5ee51ef74fa865950bb9a2757fdb33ad";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
</head>
<body>
<div class="page-group pending-page">
    <div class="page page-current" id="page-1510716015239">
        <!--标题栏-->
        <header class="bar bar-nav">
            <a class="icon icon-left pull-left" href="javascript:history.back(-1);"></a>
            <h1 class="title">全部订单</h1>
        </header>

        <!--内容区-->
        <div class="content infinite-scroll infinite-scroll-bottom native-scroll" data-distance="100">
            <input type="hidden" value="0" id="pagenum">
            <!--待付款项列表-->
            <div id="order">
                <div class="order-box">
                    <div class="order-header">
                        <h3>订单号：171115110508204<span>待付款</span></h3>
                    </div>
                    <ul>
                        <li>
                            <a href="http://m.inman.com.cn/index.php/Order/orderdetails?order_id=171115110508204" class="external" data-no-cache="true">
                                <div class="w-20 g-img"><img src="http://img.inman.com.cn/public/images/0d/79/be/183864a030a19c71cc4bdce367be592fddc9da55--w_120_h_120.jpg"></div>
                                <div class="w-60">
                                    <h4>茵曼2016秋装新款多色轻薄保暖连帽羽绒马夹女马甲背心</h4>
                                    <p>售价：￥299.00 / 数量：1</p>
                                    <p>颜色：彩蓝色 / 尺码：L</p>
                                </div>
                                <div class="w-20 g-price">
                                    <p><i>￥</i>269.00<br><span>新会员</span></p>
                                </div>
                                <div class="cb"></div>
                            </a>
                        </li>
                    </ul>
                    <div class="order-footer" data-test="1">
                        <h3><span>（共1件商品）</span>实付：<i>￥</i><strong>269.00</strong></h3>
                        <a href="javascript:;" class="btn-cancle" data-order_id="171115110508204">取消订单</a>
                        <a class="external" href="http://m.inman.com.cn/index.php/Order/orderdetails?order_id=171115110508204" data-no-cache="true">去付款</a>
                    </div>
                </div>
            </div>

            <div class="tip">
                <p>-- 已加载所有数据 --</p>
            </div>
        </div>
    </div>
    <script>
        var loading = false;
        //下拉加载
        $(document).on('infinite', '.infinite-scroll-bottom', function () {
            if(loading){
                return;
            };
            loading = true;
            $(".infinite-scroll-preloader").show();
            var uri = "http://m.inman.com.cn/index.php/Order/loadOrderlist";
            var pagenum = $("#pagenum").val();
            var type="0";
            $.ajax({
                cache: true,
                type: "POST",
                url: uri,
                data: {pagenum: parseInt(pagenum)+1,type:type},
                async: false,
                success: function (json) {
                    loading = false;
                    json = eval('(' + json + ')');
//                console.log(json);
                    if (json.errcode != '1') {
                        $.toast(json.errmsg);
                        $(".infinite-scroll-preloader").hide();
                        loading = false;
                        return false;
                    }
                    if(!json.data.orderList){
                        $.detachInfiniteScroll($('.infinite-scroll'));
                        $('.infinite-scroll-preloader').remove();
                        $('.tip').show();
                        return false;
                    }
                    var orderdata=json.data['orderList'];
                    if(typeof(orderdata)=='undefined'){
                        $(".infinite-scroll-preloader").hide();
                        $.detachInfiniteScroll($('.infinite-scroll'));
                        // 删除加载提示符
                        $('.infinite-scroll-preloader').remove();
                        return false;
                    }
                    $("#pagenum").val(parseInt(pagenum)+1);
                    var html = "";
                    var num = 0;
                    for(var key in orderdata){
                        var  goodsdata='';
                        var items=orderdata[key]['items'];
//                    console.log(items);
                        for(var key1 in items){
                            var goods_name=items[key1]['goods_name'].length>28 ? items[key1]['goods_name'].substr(0,27)+'...':items[key1]['goods_name'];
                            goodsdata+='<li><a href="http://m.inman.com.cn/index.php/Order/orderdetails?order_id='+orderdata[key]['order_id']+'" class="external"><div class="w-20 g-img"><img src="'+items[key1]['image_url'].substr(0, items[key1]['image_url'].lastIndexOf('.')) + "--w_120_h_120" + "." + items[key1]['image_url'].split('.')[items[key1]['image_url'].split('.').length - 1]+'"></div>'+
                                '<div class="w-60"><h4>'+goods_name+'</h4>'+
                                '<p>售价：￥'+items[key1]['cost']+' / 数量：'+items[key1]['nums']+'</p><p>颜色：'+items[key1]['color_name']+' / 尺码：'+items[key1]['size_name']+'</p></div><div class="w-20 g-price">'+
                                '<p><i>￥</i>'+items[key1]['final_price']+'<br><span>'+orderdata[key]['lv']+'</span></p></div><div class="cb"></div></a></li>';
                        }
                        var line='';
                        if(orderdata[key]['order_status_id']==1){
                            line='<a class="btn-cancle" href="javascript:;">取消订单</a><a class="external" href="Order/orderdetails?order_id='+key+'" data-no-cache="true">去付款</a>';
                        }
                        else if(orderdata[key]['order_status_id']==5){
                            line='<a href="Order/logistics?order_id='+key+'" class="defult">查看物流</a><a  href="javascript:;" name="confirmorder"  order-id="'+orderdata[key]['order_id']+'">确认收货</a>';
                        }
//                    if(orderdata[key]['order_status_id']==3){
//                        line='<a href="Order/aftersales?order_id='+key+'&product_id='+orderdata[key]['product_id']+'" class="defult">退款</a>';
//                    }
//                    if(orderdata[key]['order_status_id']==7){
//                        line='<a  href="javascript:void(0)" class="comment-order"  order-id="'+orderdata[key]['order_id']+'">评价晒单</a>';
//                    }
                        else if(orderdata[key]['order_status_id']==8||orderdata[key]['order_status_id']==9||orderdata[key]['order_status_id']==11||orderdata[key]['order_status_id']==12){
                            line='<a href="javascript:;" class="btn-drop defult" data-order_id="'+key+'">删除订单</a>';
                            if(orderdata[key]['payment']=='offline' && orderdata[key]['order_status_id']!=9){
                                if(orderdata[key]['com_id']){
                                    line += '<a class="external no-bg" href="/User/complaintshow?com_id=' + orderdata[key]['com_id'] + '" style="margin-left: 0.2rem;">投诉</a>';
                                } else {
                                    line += '<a class="external no-bg" href="/User/complaint?order_id=' + orderdata[key]['order_id'] + '" style="margin-left: 0.2rem;">投诉</a>';
                                }
                                line += '<a class="external no-bg" href="/shop/evaluation?order_id='+orderdata[key]['order_id']+'&shop_id='+orderdata[key]['shop_id']+'" style="margin-left: 0.2rem;">店铺评分</a>';
                            }
                            if(orderdata[key]['comment_status']==1){
                                line += '<a href="javascript:void(0)"  class="comment-order"  order-id="'+orderdata[key]['order_id']+'" style="margin-left: 0.2rem">评价晒单</a>';
                            }
                        }else{
                            if(orderdata[key]['comment_status']==1){
                                line += '<a href="javascript:void(0)"  class="comment-order"  order-id="'+orderdata[key]['order_id']+'" style="margin-left: 0.2rem">评价晒单</a>';
                            }
                        }
                        html+='<div class="order-box"><div class="order-header"><h3>订单号：'+key+'<span>'+orderdata[key]['order_status']+'</span></h3></div>'+
                            '<ul>'+goodsdata+'</ul><div class="order-footer" data-test="'+orderdata[key]['order_status_id']+'"> <h3><span>（共'+orderdata[key]['goodsCount']+'件商品）</span>实付：<i>￥</i><strong>'+orderdata[key]['final_amount']+'</strong></h3>'+line+'</div></div>';
                        num++;
                    }
//                console.log(num);
//                if(parseInt(num)<4){
//                    $(".infinite-scroll-preloader").hide();
//                    // 加载完毕，则注销无限加载事件，以防不必要的加载
//                    $.detachInfiniteScroll($('.infinite-scroll'));
//                    // 删除加载提示符
//                    $('.infinite-scroll-preloader').remove();
//                    return false;
//                }
                    $("#order").append(html);
                    clickItem();
                }
            });
        });

        $(function(){
            clickItem();
        });

        var btnClick=function(reason,order_id,that){
            return function(){
                var uri = "http://m.inman.com.cn/index.php/Order/deleteorder";
                $.showIndicator();
                $.ajax({
                    cache: true,
                    type: "post",
                    url: uri,
                    data: {order_id:order_id,reason:reason},
                    async: false,
                    success: function (json) {
                        $.hideIndicator();
                        json = eval('(' + json + ')');
                        if(json.errcode=='0'){
                            $.toast(json.errmsg);
                            return false;
                        }
                        $.toast(json.errmsg);
                        that.parent().parent().remove();
                        location.reload();
                    }
                })
            }
        };

        function clickItem(){
            $('.btn-cancle').unbind('click');
            $('.btn-drop').unbind('click');
            //取消订单
            $('.btn-cancle').click(function(){
                var order_id=$(this).attr("data-order_id");
                var uri = "http://m.inman.com.cn/index.php/Order/getCancelReason";
                var that=$(this);
                $.showIndicator();
                $.ajax({
                    cache: true,
                    type: "post",
                    url: uri,
                    data: {order_id:order_id},
                    async: false,
                    success: function (json) {
                        $.hideIndicator();
                        json = eval('(' + json + ')');
                        if(json.errcode=='0'){
                            $.toast(json.errmsg);
                            return false;
                        }
                        var reasondata=json.data;
                        var buttons1 =[];
                        for(var m=0;m<reasondata.length;m++){
                            var arr={};
                            arr.text=reasondata[m];
                            arr.onClick=btnClick(reasondata[m],order_id,that);
                            buttons1.push(arr);
                        }
                        var buttons2 = [
                            {
                                text: '取消',
                                bg: 'danger'
                            }
                        ];
                        var groups = [buttons1, buttons2];
                        $.actions(groups);
                    }
                })
            });

            //删除订单
            $('.btn-drop').click(function(){
                var order_id = $(this).attr("data-order_id");
                var uri = "http://m.inman.com.cn/index.php/Order/dropOrder";
                console.log(order_id);
                $.confirm('确定删除?', function(){
                    $.showIndicator();
                    $.ajax({
                        cache: true,
                        type: "post",
                        url: uri,
                        data: {order_id:order_id},
                        async: false,
                        success: function (json) {
                            $.hideIndicator();
                            json = eval('(' + json + ')');
                            if(json.errcode=='0'){
                                $.toast(json.errmsg);
                                return false;
                            }
                            $.toast(json.errmsg);
                            $(this).parent().parent().remove();
                            location.reload();
                        }
                    })
                });
            });

            //评价晒单
            $('.comment-order').click(function(){
                var order_id = $(this).attr('order-id');
                var url = "http://m.inman.com.cn/index.php/Order/orderCommentCheck";
                $.showIndicator();
                $.ajax({
                    cache: true,
                    type: "get",
                    url: url,
                    data: {order_id:order_id},
                    async: false,
                    success: function (json) {
                        console.log(json);
                        $.hideIndicator();
                        json = eval('(' + json + ')');
                        if(json.errcode !='1'){
                            $.toast(json.errmsg);
                            return false;
                        }else{
                            window.location.href="http://m.inman.com.cn/index.php/Order/ordercomment"+"?order_id="+order_id;
                        }
                    }
                })
            })

            //确认收货
            $("a[name='confirmorder']").click(function(){
                var order_id=$(this).attr("data-order_id");
                var uri = "http://m.inman.com.cn/index.php/Order/confrimOrder";
                var that=$(this);
                $.showIndicator();
                $.ajax({
                    cache: true,
                    type: "post",
                    url: uri,
                    data: {order_id:order_id},
                    async: false,
                    success: function (json) {
                        $.hideIndicator();
                        json = eval('(' + json + ')');
                        if(json.errcode=='0'){
                            $.toast(json.errmsg);
                            return false;
                        }
                        $.toast(json.errmsg);
                        that.parent().append("<a href='/Order/ordercomment?order_id="+order_id+"' class='default'>评价晒单</a>");
                        that.remove();
                        location.reload();
                    }
                })
            });

        }
        $.init();
    </script>
</div>

</body></html>